<#assign basePath=request.contextPath title="用户列表查询">
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<#include "/layout/header.ftl">
	<!-- DataTables Plugin -->
	<link href="/${basePath}common/theme/scripts/plugins/tables/DataTables/media/css/DT_bootstrap.css" rel="stylesheet" />
</head>
<body class="">
	<div class="container-fluid fluid menu-left">
		<#include "/layout/navbar.ftl">
		<div id="wrapper">
		<#include "/layout/sidebar.ftl">
		<div id="content">
<div class="filter-bar dark margin-bottom-none border-none"></div>
<h3 class="heading-mosaic">Overview</h3>
<div class="innerLR">
	<!-- Form -->
	
	<button class="btn btn-block btn-primary" style="width:100px" onclick="window.location.href='/${basePath}reduceProgramme/addInit.shtml'" type="button">优惠方案添加</button>
	<form action="dispatchInstance.html" class="form-horizontal" style="margin-bottom: 0;" id="validateSubmitForm" method="get" autocomplete="off">
		
		<!-- Widget -->
		<div class="widget" data-toggle="collapse-widget">
		
			<!-- Widget heading -->
			<div class="widget-head">
				<h4 class="heading">商品优惠列表</h4>
			</div>
			<!-- // Widget heading END -->
			
			<div class="widget-body">
			
				<!-- Row -->
				<div class="row-fluid">
				
					<!-- Column -->
					<div class="span6">
					
						<!-- Group -->
						<div class="control-group">
							<label class="control-label" for="dispatchInstanceId">id:</label>
							<div class="controls"><input style='color: black;' class="span8" id="id" name="id" type="text" /></div>
						</div>
					
						
						<!-- Group -->
						<div class="control-group">
							<label class="control-label" for="stat">优惠方案名称:</label>
							<div class="controls">
							<input style="color: black;" type="text" id="name" name="name">
								
							</div>
						</div>
						
					</div>
					<!-- // Column END -->
					
		
					<!-- // Column END -->
					
				</div>
				<!-- // Row END -->
				
				<hr class="separator" />
				
				<!-- Form actions -->
				<div class="form-actions">
				<div class="span2 center"><button class="btn btn-block btn-primary" onclick="find()" type="button">查询</button></div>
				</div>
				<!-- // Form actions END -->
				
			</div>
		</div>
		<!-- // Widget END -->
		
	</form>
	<!-- // Form END -->
	
	<!-- Widget -->
	<div class="widget">
		
		<!-- Widget heading -->
		<div class="widget-head">
			<h4 class="heading">Data Table</h4>
		</div>
		<!-- // Widget heading END -->
		
		<div class="widget-body">
			
			<!-- Table -->
			<table class="dynamicTable table table-striped table-bordered table-condensed">
			
				<!-- Table heading -->
				<thead>
					<tr>
						<th>ID</th>
						<th>优惠方案名称</th>
						<th>优惠类型</th>
						<th>创建时间</th>
						<th>参数1</th>
						<th>参数2</th>
					
					</tr>
				</thead>
				<!-- // Table heading END -->
				<!-- Table body -->
				<tbody id="listdata">
					<!-- 列表显示 -->				
				</tbody>
				<!-- // Table body END -->
			</table>
			<!-- // Table END -->
			
			 <p>
                <div class="text-center">
                     <ul class="pagination" id="pageUl">  </ul>
                     <select id="rowchange" onchange="getRowData()" class="selectpicker span8" id="stat" name="stat" style="color: black;width: 80px;margin-top: -57px;">
								<option value="10" selected="selected">10</option>
								<option value="30" >30</option>
								<option value="50">50</option>
								<option value="100">100</option>
								<option value="200">200</option>
					</select>
                </div>
            </p>
			
		</div>
	</div>
	<!-- // Widget END -->
</div>
</div>
</div>
<div class="clearfix"></div>
<#include "/layout/footer.ftl">
</div>
<#include "/layout/bottom.ftl">
<#include "/layout/script.ftl">
<script src="/${basePath}/common/theme/scripts/plugins/tables/DataTables/media/js/jquery.dataTables.min.js"></script>
<script src="/${basePath}/common/theme/scripts/plugins/tables/DataTables/media/js/DT_bootstrap.js"></script>


<script src="/${basePath}/common/bootstrap/js/bootstrap-paginator.js"></script>


<script type="text/javascript">

var url = 'reduceProgramme/list.shtml'
				
var pagenow = 1;
var json = {};
var row = 10; 
var visiblePages = 7;
var total = 0;
json.stat = $("#stat").val();
function search(){
	json.start = pagenow;
	json.row=row;
	 $.ajax({url:url,dataType:"json",  contentType : 'application/json', type:"post",data:json,success:function(result){
		console.log(result)
		//result = eval('('+result+')')
		var total = 0;
		
		$('#listdata').html("")
		for(var i = 0 ;i < result['data'].length ; i++){
			var entity = result['list'][i];
			if(entity['type'] == 1){	
				entity['type'] = '普通用户'
			}else if(entity['type'] == 2){
				entity['type'] = '团建队长'
			}else{
				entity['type'] = '团队管家'
			}
			var province = "";
			if(entity['province'] != null){
				province= entity['province']['name'];
			}
			var city = "";
			if(entity['city'] != null){
				city= entity['city']['name'];
			}
			if(entity['sex'] ==1){
				entity['sex'] = "男"
			}else{
				entity['sex'] = "女"
			}
			$('#listdata').append('<tr class="gradeA"><td>'
			+entity['uuid']+'</td><td>'+entity['username']+'</td><td>'
			+entity['tel']+'</td><td>'
			+entity['type']+'</td><td>'
			+entity['birthDay']+'</td><td>'
			+province+'</td><td>'+city+'</td><td>'
			+entity['sex']+'</td><td><button class="btn btn-block btn-primary" onclick="window.location.href=\'/${basePath}/user/detailUser.shtml?tel='+entity['tel']+'\'" type="button">查询</button></td></tr>')
		}
		result['count'] = result['data1'];
		if(result['data1']== 0){
			result['count']=1;
		}
		if(result['count']%row >0){
			total = parseInt(result['count']/row)+1;
		}else{
			total = parseInt(result['count']/row);
		}
		var element = $('#pageUl');//对应下面ul的ID  
	    var options = {  
			bootstrapMajorVersion:3,  
	        currentPage: pagenow,//当前页面  
	        numberOfPages: 5,//一页显示几个按钮（在ul里面生成5个li）  
	        totalPages:total, //总页数
	        onPageChanged:function (event, originalEvent, typePage, currentPage) {
	        	pagenow = typePage;
				search()
	        }
	 
		}
		element.bootstrapPaginator(options); 
		
		 
                   
                   
		
    }});
}
search();

function getRowData(){
	row = $("#rowchange").val();
	pagenow =1;
	search();
}
function find(){
	json = {};
	if($("#tel").val()!="" ){
		json.tel = $("#tel").val()
	}
	if($("#username").val()!="" ){
		json.username = $("#username").val()
	}
	
	if($("#trigger").val()!="" ){
		json.type = $("#type").val()
	}
	
	console.log(json)
	pagenow = 1;
	search()
}
function cancel(){
	json = {};
	pagenow = 1;
	search();
}

</script>

</body>
</html>